package com.javasm;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.AutoConfigurationImportSelector;
import org.springframework.boot.autoconfigure.AutoConfigurationPackage;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.*;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;

//主配置类,可以(exclude = MultipartAutoConfiguration.class)排除指定的预配置类
//@Configuration
//@ComponentScan("com.javasm")
//@Import({WebMvcAutoConfiguration.class,MultipartAutoConfiguration.class})
@SpringBootApplication
@MapperScan("com.javasm.dao")// DataSource映射指定dao对象(mybatis)
@EnableTransactionManagement //事务注解识别 @Transactional
@EnableAspectJAutoProxy //aspectj注解识别
@EnableCaching //缓存注解识别
@EnableAsync //异步注解识别 @Async
@EnableScheduling //定时任务注解识别 @Scheduled  (默认单线程定时任务串行同步)  核心：对SchedulingConfigurer任务调度的bean对象执行configureTasks方法
/*
在Spring Boot的主类上添加@ServletComponentScan注解，以启用对@WebServlet注解的组件扫描
*/
@ServletComponentScan
public class BootApp {
    public static void main(String[] args) {
        //实例化容器,刷新容器(此时要加载配置类,启用包扫描,配置包扫描范围,导入预配置类),启动tomcat
        SpringApplication.run(BootApp.class,args);
    }
}
